<!DOCTYPE html>
<html lang="zh_CN">

<head>
    <title>渲染效果(滤镜)</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="图形系统开发实战:进阶篇 示例">
    <meta name="author" content="hjq">
    <meta name="keywords" content="canvas,anygraph,javascript">
    <!-- frame所需脚本和样式 -->
    <link rel="stylesheet" href="../../script/bootstrap-3.3.5/css/bootstrap.min.css">   
    <link rel="stylesheet" href="../../script/codemirror/codemirror.css">
    <script src="../../script/lib/jquery-1.11.2.min.js"></script>
    <script src="../../script/codemirror/codemirror_merge.js"></script>
    <!-- 加载代码块 -->
	<link rel="stylesheet" href="../css/styles.css">
    <script src="../js/helper.js"></script>
    <script>
        var pageTitle = "滤镜";
        var pageDesc = "滤镜效果";
    </script>
    
    <style type="text/css">
        .inner {
            width: 100%;
            height: 400px;
            border: 1px #CCC solid;
        }
        .border { 
            text-align:center;
        }
        .border span {
            font-size: 24px;
            padding: 20px;
        }
    </style>
    <script type="module">
        import { Ladder } from "../../src/index.js";

        $(document).ready(function () {
            let fileUrl = "../../demo-data/svg/girl.svg";

            let filterList = ["", "black", "blur", "brighten", "castingd", "contrast", "emboss", "enhancea", "grayscale", "hsl", "hsv", "invert", "kaleidoscope", "mask", "noise", "pixelate", "posterize", "rgba", "rgb", "rgbmask", "sepia", "solarize", "threshold"];
            let idx = 1;
            filterList.forEach(filter => {
                loadGraph(idx, fileUrl, filter);
                idx ++;
            })
        });

        function loadGraph(idx, fileUrl, filterName) {
            console.info("load file :" + fileUrl);
            let warp1 = "div_g_" + idx;
            let strHtml = [];
            strHtml.push('<div class="border col-md-4">');
            strHtml.push('<span>' + (filterName == "" ? "原图" : filterName) + '</span>');
            strHtml.push('<div class="inner" id="' + warp1 + '"></div>');
            strHtml.push('</div>');
            $("#graphWarp").append(strHtml.join(""));

            // 使用Graph显示SVG
            Ladder.loadSVGFile({
                "fileUrl": fileUrl,
                "container": warp1,
                "filter": filterName
            });
        }

    </script>
</head>

<body oncontextmenu="return false;">
    <div id="wrap">
        <div id="graphWarp" style="width:100%; height:800px; border:solid 0px #CCC;"></div>
    </div>
    <div class="clearfix visible-md-block visible-lg-block"></div>
</body>

</html>
